<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>

        /* 子元素如果将宽度设置为100%那么它是相对于父元素宽度的100%
            但是如果子元素开启了绝对地位，那么它的宽度相对的是包含块的宽度
        */
        .box1{
            width: 800px;
            height: 800px;
            background-color: cadetblue;
            position: relative;
        }

        .box2{
            width: 500px;
            height: 500px;
            background-color: chartreuse;
        }

        .box3{
            width: 100%;
            height: 200px;
            background-color: chocolate;
            position:absolute;
        }




    </style>
</head>
<body>
    <div class="box1">
        <div class="box2">
            <div class="box3"></div>
        </div>
    </div>
</body>
</html>